<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns:MSHelp="http://www.microsoft.com/MSHelp/" lang="en-us" xml:lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="DC.Type" content="reference">
<meta name="DC.Title" content="concurrent_lru_cache Template Class">
<meta name="DC.subject" content="concurrent_lru_cache Template Class">
<meta name="keywords" content="concurrent_lru_cache Template Class">
<meta name="DC.Relation" scheme="URI" content="../../../reference/appendices/community_preview_features.htm">
<meta name="DC.Relation" scheme="URI" content="../../../reference/appendices/community_preview_features/concurrent_lru_cache_cls/handle_object_cls.htm">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="concurrent_lru_cache_cls">
<meta name="DC.Language" content="en-US">
<link rel="stylesheet" type="text/css" href="../../../intel_css_styles.css">
<title>concurrent_lru_cache Template Class</title>
<xml>
<MSHelp:Attr Name="DocSet" Value="Intel"></MSHelp:Attr>
<MSHelp:Attr Name="Locale" Value="kbEnglish"></MSHelp:Attr>
<MSHelp:Attr Name="TopicType" Value="kbReference"></MSHelp:Attr>
</xml>
</head>
<body id="concurrent_lru_cache_cls">
 <!-- ==============(Start:NavScript)================= -->
 <script src="..\..\..\NavScript.js" language="JavaScript1.2" type="text/javascript"></script>
 <script language="JavaScript1.2" type="text/javascript">WriteNavLink(3);</script>
 <!-- ==============(End:NavScript)================= -->
<a name="concurrent_lru_cache_cls"><!-- --></a>

 
  <h1 class="topictitle1">concurrent_lru_cache Template Class</h1>
 
   
  <div> 
	 <div class="section"><h2 class="sectiontitle">Summary</h2> 
		 
		<p>Template class for Least Recently Used cache with
		  concurrent operations. 
		</p>
 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Syntax</h2> 
		 
		<pre>template &lt;typename key_type, typename value_type, typename value_functor_type = value_type (*)(key_type) &gt;
 class concurrent_lru_cache;</pre> 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Header</h2> 
		 
		<pre>#define TBB_PREVIEW_CONCURRENT_LRU_CACHE 1
 #include "tbb/concurrent_lru_cache.h"</pre> 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Description</h2> 
		 
		<p>A 
		  <span class="keyword">concurrent_lru_cache</span> container maps keys to values
		  with the ability to limit the number of stored unused objects. There is at most
		  one element in the container for each key. 
		</p>
 
		<p>The container permits multiple threads to
		  concurrently retrieve items from it. 
		</p>
 
		<p>The container tracks the lifetime of retrieved
		  items by returning a proxy object instead of a real value. 
		</p>
 
		<p>The container stores all the items that are
		  currently in use and a limited number of unused items. Extra items are removed
		  in a least recently used manner. 
		</p>
 
		<p>When no item is found for a key, the container
		  calls the user provided function object to get a needed value and inserts it.
		  The functor object must be thread safe. 
		</p>
 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Members</h2> 
		 
		<pre>namespace tbb {
 template &lt;typename key_type,
 typename value_type,
 typename value_functor_type = value_type (*)(key_type) &gt;
 class concurrent_lru_cache{
 private:
 class handle_object;
 public:
 typedef handle_object handle;
 public:
 concurrent_lru_cache(value_functor_type f,<u>std::size_t</u> number_of_lru_history_items);
 handle_object operator()(key_type k);
 private:
 struct handle_move_t;
 class handle_object {
 public:
 handle_object(handle_move_t m);
 operator handle_move_t();
 value_type&amp; value();
 ~handle_object();
 friend handle_move_t move(handle_object&amp; h);
 private:
 void operator=(handle_object&amp;);
 handle_object(handle_object &amp;);
 };
<u>};</u>
 }</pre> 
		
<div class="tablenoborder"><table cellpadding="4" summary="" frame="border" border="1" cellspacing="0" rules="all"><span class="tabledesc">The following table provides additional information on the
			 members of this template class. 
		  </span><thead align="left"> 
				<tr> 
				  <th class="cellrowborder" valign="top" width="33.89830508474576%" id="d18666e159">Member 
				  </th>
 
				  <th class="cellrowborder" valign="top" width="66.10169491525423%" id="d18666e162">Description 
				  </th>
 
				</tr>
</thead>
 
			 <tbody> 
				<tr> 
				  <td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d18666e159 "><span class="keyword"></span>concurrent_lru_cache(value_function_type f,<u>std::size_t</u> number_of_lru_history_items); 
				  </td>
 
				  <td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d18666e162 "> 
					 <p>Constructs an empty cache with a 
						<samp class="codeph">number_of_lru_history_items</samp> maximum
						number of stored unused objects, and 
						<samp class="codeph">f</samp> function
						object returning new values. 
					 </p>
 
				  </td>
 
				</tr>
 
				<tr> 
				  <td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d18666e159 "><span class="keyword">handle_object operator[](key_type
						k)</span> 
				  </td>
 
				  <td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d18666e162 "> 
					 <p>Search the container for a pair with
						given key. If the pair is not found, the user provided function object is
						called to get the value and insert it into the container. 
					 </p>
 
					 <p><strong>Returns</strong>: 
						<samp class="codeph">handle_object</samp> pointing to the matching
						value. 
					 </p>
 
				  </td>
 
				</tr>
 
				<tr> 
				  <td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d18666e159 "><span class="keyword">~ concurrent_lru_cache
						()</span> 
				  </td>
 
				  <td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d18666e162 "> 
					 <p>Destroys all items in the container, and
						the container itself, so that it can no longer be used. 
					 </p>
 
				  </td>
 
				</tr>
 
				<tr> 
				  <td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d18666e159 "><span class="keyword">handle_object class</span> 
				  </td>
 
				  <td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d18666e162 "><a href="concurrent_lru_cache_cls/handle_object_cls.htm">More Info</a> 
				  </td>
 
				</tr>
 
				<tr> 
				  <td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d18666e159 "><span class="keyword">handle_move_t class</span> 
				  </td>
 
				  <td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d18666e162 "> 
					 <p>This is an instrumental class to allow
						certain conversions that allow ownership transfer between instances of 
						<samp class="codeph">handle_object</samp> objects. As well it
						allows 
						<samp class="codeph">handle_object</samp> objects to be passed to
						and returned from functions. The class has no members other than holding a
						reference to value object in LRU cache container and a pointer to the container
						itself. 
					 </p>
 
				  </td>
 
				</tr>
 
			 </tbody>
 
		  </table>
</div>
 
	 </div>
 
  </div>


<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong>&nbsp;<a href="../../../reference/appendices/community_preview_features.htm">Community Preview Features</a></div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><a href="../../../reference/appendices/community_preview_features/concurrent_lru_cache_cls/handle_object_cls.htm">handle_object class</a><br>
</li>
</ul>
</div>

</body>
</html>
